API Documentation
Texture.h
1 // Texture.h
3 //
5 
6 namespace nkGraphics
7 {
11  enum class TEX_TYPE
12  {
13  TEX_2D = 0,
14  TEX_3D,
16  } ;
17 
21  enum class TEX_RENDER_FLAG
22  {
23  NO_RENDER = 0,
26  } ;
27 }
28 
29 namespace nkGraphics
30 {
35  {
36  public :
37 
41  Texture () ;
45  virtual ~Texture () ;
46 
50  virtual void setResourcePath (const nkMemory::StringView& path) override ;
51 
59  bool isFromFile () const ;
63  bool isGammaCorrected () const ;
67  bool isBackBufferTex () const ;
71  TEX_TYPE getTexType () const ;
79  unsigned int getNeededMipsForSize () const ;
83  virtual int getWidth () const = 0 ;
87  virtual int getHeight () const = 0 ;
91  virtual int getDepthOrArraySize () const = 0 ;
95  virtual unsigned int getMipLevels () const = 0 ;
99  virtual FORMAT getTextureFormat () const = 0 ;
103  virtual CPU_ACCESS_FLAG getCpuAccessRights () const = 0 ;
107  virtual USAGE getTextureUsage () const = 0 ;
111  virtual BIND_FLAG getTextureBinding () const = 0 ;
115  virtual RESOURCE_MISC_FLAG getMiscFlag () const = 0 ;
119  virtual unsigned int getSampleCount () const = 0 ;
123  virtual unsigned int getSampleQuality () const = 0 ;
127  virtual bool getAutoMipGeneration () const = 0 ;
128 
129  // Setters
159  void setBackBufferTex (bool value) ;
175  void setFromImage (const nkImages::ImageView& image) ;
182  virtual void freeCpuData (bool freeDataPtr) ;
193  virtual void setGammaCorrected (bool value) ;
197  virtual void setWidth (unsigned int width) = 0 ;
201  virtual void setHeight (unsigned int height) = 0 ;
205  virtual void setDepthOrArraySize (unsigned int value) = 0 ;
211  virtual void setMipLevels (unsigned int value) = 0 ;
215  virtual void setTextureFormat (FORMAT format) = 0 ;
221  virtual void setCpuAccessRights (CPU_ACCESS_FLAG rights) = 0 ;
225  virtual void setTextureUsage (USAGE usage) = 0 ;
229  virtual void setTextureBinding (BIND_FLAG binding) = 0 ;
233  virtual void setAutoMipGeneration (bool value) = 0 ;
239  virtual void copyParams (const Texture& other) = 0 ;
244 
248  virtual void prepareAsTexture2d () ;
252  virtual void prepareAsCubemap () ;
256  virtual void prepareAsTexture3d () ;
262  virtual void setRenderFlag (TEX_RENDER_FLAG value) ;
263 
270  virtual bool preLoadFromFile () = 0 ;
271 
282  nkImages::Image convertToImage (int mip, int sliceOrArrayIndex) ;
290  virtual MapResult map (const MapRequestDescriptor& requestDesc) = 0 ;
298  virtual void unmap (const UnmapRequestDescriptor& requestDesc) = 0 ;
307  virtual void gpuCopyFrom (Texture& other, const ResourceGpuCopyDescriptor& descriptor) = 0 ;
308 
314  virtual void exportClassToTree (nkExport::Node* rootNode) override ;
320  virtual void importClassFromTree (nkExport::Node* rootNode) override ;
321  } ;
322 }
nkGraphics::MapResult
Contains all information of the result of a map operation on a resource.
Definition: MapResult.h:12
nkGraphics::Texture::getAutoMipGeneration
virtual bool getAutoMipGeneration() const =0
nkGraphics::RESOURCE_MISC_FLAG
RESOURCE_MISC_FLAG
Available misc flags for resources.
Definition: DxDefinesWrapper.h:56
nkGraphics::Texture::getSampleCount
virtual unsigned int getSampleCount() const =0
nkGraphics::MapRequestDescriptor
A description of a request to map a resource.
Definition: MapRequestDescriptor.h:29
nkGraphics::Texture::setDepthOrArraySize
virtual void setDepthOrArraySize(unsigned int value)=0
nkGraphics::Texture::isGammaCorrected
bool isGammaCorrected() const
nkGraphics::Texture::prepareAsCubemap
virtual void prepareAsCubemap()
nkGraphics::Texture::Texture
Texture()
nkGraphics::TEX_TYPE::TEX_CUBEMAP
@ TEX_CUBEMAP
A cubemap.
nkGraphics::Texture::getCpuAccessRights
virtual CPU_ACCESS_FLAG getCpuAccessRights() const =0
nkGraphics::Texture::getMipLevels
virtual unsigned int getMipLevels() const =0
nkGraphics::Texture::isFromFile
bool isFromFile() const
nkGraphics::Texture
A texture used for rendering, hosted on GPU.
Definition: Texture.h:35
nkGraphics::Texture::unmap
virtual void unmap(const UnmapRequestDescriptor &requestDesc)=0
nkGraphics::Texture::getMiscFlag
virtual RESOURCE_MISC_FLAG getMiscFlag() const =0
nkExport::Exportable
An interface to define objects that can be exported using this component.
Definition: Exportable.h:15
nkGraphics::BIND_FLAG
BIND_FLAG
Available binding flags for a resources.
Definition: DxDefinesWrapper.h:25
nkImages::ImageView
Holds all information required for an image, with no ownership over the data.
Definition: ImageView.h:14
nkGraphics::Texture::copyParams
virtual void copyParams(const Texture &other)=0
nkGraphics::UnmapRequestDescriptor
Description of an unmap request.
Definition: UnmapRequestDescriptor.h:19
nkGraphics::TEX_RENDER_FLAG::DEPTH_RENDER_TARGET
@ DEPTH_RENDER_TARGET
Used as a depth target rendering.
nkGraphics::Texture::setTextureBinding
virtual void setTextureBinding(BIND_FLAG binding)=0
nkGraphics::Texture::getTextureFormat
virtual FORMAT getTextureFormat() const =0
nkGraphics::TEX_RENDER_FLAG::RENDER_TARGET
@ RENDER_TARGET
Used as a color target rendering.
nkGraphics::USAGE
USAGE
Available usage for resources. Drives the memory used for hosting the data.
Definition: DxDefinesWrapper.h:13
nkGraphics::Texture::setMipLevels
virtual void setMipLevels(unsigned int value)=0
nkGraphics::Texture::getTextureBinding
virtual BIND_FLAG getTextureBinding() const =0
nkGraphics::Texture::prepareAsTexture2d
virtual void prepareAsTexture2d()
nkExport::Node
A node in the tree structure representing the data to export / import.
Definition: Node.h:42
nkGraphics::Texture::setAutoMipGeneration
virtual void setAutoMipGeneration(bool value)=0
nkGraphics::Texture::importClassFromTree
virtual void importClassFromTree(nkExport::Node *rootNode) override
nkGraphics::Texture::getTextureUsage
virtual USAGE getTextureUsage() const =0
nkGraphics::Texture::~Texture
virtual ~Texture()
nkGraphics::Texture::setCpuData
void setCpuData(const ResourceCpuDataDescriptor &data)
nkGraphics::Texture::getCpuData
ResourceCpuDataDescriptor * getCpuData() const
nkGraphics::Texture::freeCpuData
virtual void freeCpuData(bool freeDataPtr)
nkGraphics::Texture::setFromImage
void setFromImage(const nkImages::ImageView &image)
nkGraphics::TEX_TYPE
TEX_TYPE
The type a texture can be.
Definition: Texture.h:12
nkGraphics::Texture::setHeight
virtual void setHeight(unsigned int height)=0
nkGraphics::Texture::getWidth
virtual int getWidth() const =0
nkGraphics::ResourceCpuDataDescriptor
Describes data on the cpu, to be uploaded to the gpu.
Definition: ResourceCpuDataDescriptor.h:12
nkGraphics::Texture::getTexType
TEX_TYPE getTexType() const
nkMemory::StringView
Class holding information about a string, with no ownership over the data.
Definition: StringView.h:22
nkGraphics::Texture::setGammaCorrected
virtual void setGammaCorrected(bool value)
nkGraphics::Texture::setTextureFormat
virtual void setTextureFormat(FORMAT format)=0
nkGraphics::Texture::exportClassToTree
virtual void exportClassToTree(nkExport::Node *rootNode) override
nkGraphics::Texture::getSampleQuality
virtual unsigned int getSampleQuality() const =0
nkGraphics::Texture::isBackBufferTex
bool isBackBufferTex() const
nkGraphics::CPU_ACCESS_FLAG
CPU_ACCESS_FLAG
Available cpu access flags.
Definition: DxDefinesWrapper.h:44
nkGraphics::Texture::setTextureFormatFromString
void setTextureFormatFromString(const nkMemory::StringView &str)
nkGraphics::Texture::setTextureUsage
virtual void setTextureUsage(USAGE usage)=0
nkGraphics::TEX_TYPE::TEX_2D
@ TEX_2D
A 2D texture.
nkGraphics::Texture::setWidth
virtual void setWidth(unsigned int width)=0
nkGraphics::Texture::setRenderFlag
virtual void setRenderFlag(TEX_RENDER_FLAG value)
nkGraphics::Texture::setBackBufferTex
void setBackBufferTex(bool value)
nkGraphics::TEX_RENDER_FLAG::NO_RENDER
@ NO_RENDER
Not used as a target.
nkGraphics::Texture::setCpuAccessRights
virtual void setCpuAccessRights(CPU_ACCESS_FLAG rights)=0
nkGraphics::Texture::getDepthOrArraySize
virtual int getDepthOrArraySize() const =0
nkGraphics::Texture::getNeededMipsForSize
unsigned int getNeededMipsForSize() const
nkGraphics::FORMAT
FORMAT
Available formats for resources.
Definition: DxDefinesWrapper.h:155
nkGraphics::Texture::getRenderFlag
TEX_RENDER_FLAG getRenderFlag() const
nkGraphics::Texture::prepareAsTexture3d
virtual void prepareAsTexture3d()
nkGraphics
Encompasses all API of component NilkinsGraphics.
Definition: BoundingBox.h:7
nkGraphics::Texture::map
virtual MapResult map(const MapRequestDescriptor &requestDesc)=0
nkGraphics::ResourceGpuCopyDescriptor
Holds information about a resource copy happening on the GPU only.
Definition: ResourceGpuCopyDescriptor.h:12
nkGraphics::TEX_RENDER_FLAG
TEX_RENDER_FLAG
The render flag possible for a texture.
Definition: Texture.h:22
nkGraphics::TEX_TYPE::TEX_3D
@ TEX_3D
A 3D texture.
nkGraphics::Texture::getHeight
virtual int getHeight() const =0
nkImages::Image
Holds all information required for an image, with ownership over the data.
Definition: Image.h:14
nkGraphics::Texture::gpuCopyFrom
virtual void gpuCopyFrom(Texture &other, const ResourceGpuCopyDescriptor &descriptor)=0
nkGraphics::Texture::setResourcePath
virtual void setResourcePath(const nkMemory::StringView &path) override
nkGraphics::Texture::preLoadFromFile
virtual bool preLoadFromFile()=0
nkGraphics::Texture::convertToImage
nkImages::Image convertToImage(int mip, int sliceOrArrayIndex)
nkGraphics::ShaderResource
Base class for shader resources. Those are resources that can be fed to a Shader.
Definition: ShaderResource.h:12